﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace loginSQL.Util
{
    public class PageData
    {
        Dictionary<String, PointF> datasource;
        Dictionary<String, Boolean> visible;
        public String BackgroundFile
        {
            get;
            set;
        }

        public Dictionary<String, PointF> DataSource
        {
            get
            {
                return datasource;
            }
        }

        public Dictionary<String, Boolean> Visibility
        {
            get
            {
                return visible;
            }
        }

        public List<String> AttributeName
        {
            get
            {
                return datasource.Keys.ToList();
            }
        }

        public PageData()
        {
            datasource = new Dictionary<string, PointF>();
            visible = new Dictionary<string, bool>();
            BackgroundFile = "";
            foreach (String name in Users.FieldName)
            {
                SetData(name, new PointF(0, 0), false);
            }
        }

        public bool IsVisible(String keyAttribute)
        {
            return visible[keyAttribute];
        }

        public void ToggleVisibility(String keyAttribute)
        {
            visible[keyAttribute] = !visible[keyAttribute];
        }

        public void SetVisibility(String keyAttribute, bool value)
        {
            visible[keyAttribute] = value;
        }

        public PointF GetData(String keyAttribute)
        {
            return datasource[keyAttribute];
        }

        public void RemoveData(String keyAttribute)
        {
            datasource.Remove(keyAttribute);
            visible.Remove(keyAttribute);
        }

        public void SetData(String keyAttribute,PointF value)
        {
            if (datasource.ContainsKey(keyAttribute))
            {
                datasource[keyAttribute] = value;
            }
            else
            {
                datasource.Add(keyAttribute, value);
                visible.Add(keyAttribute, false);
            }
        }

        public void SetData(String keyAttribute, PointF value, bool visibility)
        {
            SetData(keyAttribute, value);
            SetVisibility(keyAttribute,visibility);
        }
    }
}
